<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
  xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
  xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
  xmlns:dentalConverters="clr-namespace:DentalConfig.Converters;assembly=DentalConfig"
  xmlns:dgh="clr-namespace:DentalGUIHelper;assembly=DentalConfig"
  xmlns:system="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="../Brushes/MaterialDesign/MaterialDesignTheme.Theme.xaml"/>
    <ResourceDictionary Source="MaterialDesignTheme.Shadows.xaml"/>
    <ResourceDictionary>
      <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    </ResourceDictionary>
    <ResourceDictionary Source="../NamedStyles/MaterialDesignTheme.NamedTextBlock.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <Style x:Key="FocusVisual">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <converters:RangeLengthConverter x:Key="RangeLengthConverter"/>
  <converters:MathConverter x:Key="MathAddConverter" Operation="Add"/>
  <dentalConverters:SequentialValueConverter x:Key="TranslateAndToUpper">
    <dentalConverters:TranslationConverter/>
    <dentalConverters:ToUpperConverter/>
  </dentalConverters:SequentialValueConverter>
  <dentalConverters:HorizontalAlignmentToAlignmentXConverter x:Key="HorizontalAlignmentToAlignmentX"/>
  <dentalConverters:BrushToTransmittantBrushConverter x:Key="BrushToTransmittantBrushConverter"/>
  <system:Int32 x:Key="ProgressRingStrokeWidth">8</system:Int32>

  <SolidColorBrush x:Key="AttentionToActionBrush" Color="{StaticResource MaterialDesignShadow}" Opacity=".23" po:Freeze="True"/>

  <Style x:Key="OverlayFocusVisual">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Border CornerRadius="2" Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Foreground, Converter={StaticResource BrushToTransmittantBrushConverter}, ConverterParameter=0.24}"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignRaisedButton" TargetType="{x:Type ButtonBase}">
    <Style.Resources>
      <Style x:Key="{x:Type TextBlock}" BasedOn="{StaticResource ControlContentTextblock}" TargetType="{x:Type TextBlock}"/>
    </Style.Resources>
    <Setter Property="FocusVisualStyle" Value="{StaticResource OverlayFocusVisual}"/>
    <Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorForeground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorBackground" Value="{DynamicResource PrimaryHueMidBrush}"/>
    <Setter Property="wpf:RippleAssist.Feedback" Value="{Binding Foreground, RelativeSource={RelativeSource Self}}"/>
    <Setter Property="Cursor" Value="Hand"/>
    <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth1"/>
    <Setter Property="TextBlock.FontFamily" Value="{DynamicResource ButtonFontFamily}"/>
    <Setter Property="TextBlock.FontWeight" Value="Medium"/>
    <Setter Property="TextBlock.FontSize" Value="{DynamicResource BaseButtonFontSize}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Padding" Value="4"/>
    <Setter Property="MinHeight" Value="24"/>
    <Setter Property="wpf:ButtonProgressAssist.IsIndicatorVisible" Value="False"/>
    <Setter Property="wpf:ButtonProgressAssist.Opacity" Value=".4"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Grid>
            <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
              <Grid>
                <Border
                  Background="{TemplateBinding Background}"
                  CornerRadius="2"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  x:Name="border"
                  Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}"/>
                <ProgressBar
                  x:Name="ProgressBar"
                  Style="{DynamicResource MaterialDesignLinearProgressBar}"
                  Minimum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Minimum)}"
                  Maximum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Maximum)}"
                  Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorForeground)}"
                  Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorBackground)}"
                  Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Value)}"
                  IsIndeterminate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IsIndeterminate)}"
                  Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IsIndicatorVisible), Converter={StaticResource BooleanToVisibilityConverter}}"
                  Height="{TemplateBinding Height}"
                  Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ButtonBase}}, Path=ActualWidth}"
                  Opacity="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Opacity)}"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Center"></ProgressBar>
              </Grid>
            </AdornerDecorator>
            <wpf:Ripple
              Content="{TemplateBinding Content}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              ContentStringFormat="{TemplateBinding ContentStringFormat}"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsFocused" Value="True">
              <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
              <Setter TargetName="border" Property="wpf:ShadowAssist.Darken" Value="True"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
              <Setter TargetName="border" Property="wpf:ShadowAssist.Darken" Value="True"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignUpperRaisedButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignRaisedButton}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <ControlTemplate.Resources>
            <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource UpperTextBlock}"/>
          </ControlTemplate.Resources>
          <Grid>
            <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
              <Grid>
                <Border
                  Background="{TemplateBinding Background}"
                  CornerRadius="2"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  x:Name="border"
                  Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}"/>
                <ProgressBar
                  x:Name="ProgressBar"
                  Style="{DynamicResource MaterialDesignLinearProgressBar}"
                  Minimum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Minimum)}"
                  Maximum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Maximum)}"
                  Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorForeground)}"
                  Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorBackground)}"
                  Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Value)}"
                  IsIndeterminate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IsIndeterminate)}"
                  Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IsIndicatorVisible), Converter={StaticResource BooleanToVisibilityConverter}}"
                  Height="{TemplateBinding Height}"
                  Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ButtonBase}}, Path=ActualWidth}"
                  Opacity="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Opacity)}"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Center"></ProgressBar>
              </Grid>
            </AdornerDecorator>
            <wpf:Ripple
              Tag="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
              Content="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource TranslateAndToUpper}}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              ContentStringFormat="{TemplateBinding ContentStringFormat}"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsFocused" Value="True">
              <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
              <Setter TargetName="border" Property="wpf:ShadowAssist.Darken" Value="True"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
              <Setter TargetName="border" Property="wpf:ShadowAssist.Darken" Value="True"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
              <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
              <Setter TargetName="border" Property="wpf:ShadowAssist.Darken" Value="True"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignRaisedLightButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignRaisedButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignRaisedDarkButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignRaisedButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueDarkBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueDarkBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueDarkForegroundBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignRaisedAccentButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignRaisedButton}">
    <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFlatButton" TargetType="{x:Type ButtonBase}">
    <Style.Resources>
      <Style x:Key="{x:Type TextBlock}" BasedOn="{StaticResource ControlContentTextblock}" TargetType="{x:Type TextBlock}"/>
    </Style.Resources>
    <Setter Property="FocusVisualStyle" Value="{StaticResource OverlayFocusVisual}"/>
    <Setter Property="Background" Value="{DynamicResource MaterialDesignFlatButtonClick}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignFlatButtonClick}"/>
    <Setter Property="Cursor" Value="Hand"/>
    <Setter Property="Foreground" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="wpf:RippleAssist.Feedback" Value="{DynamicResource MaterialDesignFlatButtonRipple}"/>
    <Setter Property="TextBlock.FontFamily" Value="{DynamicResource ButtonFontFamily}"/>
    <Setter Property="TextBlock.FontWeight" Value="Medium"/>
    <Setter Property="TextBlock.FontSize" Value="{DynamicResource BaseButtonFontSize}"/>
    <Setter Property="BorderThickness" Value="0"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Padding" Value="4"/>
    <Setter Property="MinHeight" Value="24"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <ControlTemplate.Resources>
            <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource UpperTextBlock}"/>
          </ControlTemplate.Resources>
          <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}">
            <wpf:Ripple
              Tag="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
              Content="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource TranslateAndToUpper}}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatTextButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}">
            <wpf:Ripple
              Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatButtonColored" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatButton}">
	<Setter Property="Background" Value="{Binding Background, RelativeSource={RelativeSource Self}}"/>
	<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}"/>
	<Setter Property="BorderThickness" Value="1"/>
	<Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <ControlTemplate.Resources>
            <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource UpperTextBlock}"/>
          </ControlTemplate.Resources>
          <Border Background="{TemplateBinding Background}" x:Name="border" CornerRadius="2" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}">
            <wpf:Ripple
              Tag="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
              Content="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource TranslateAndToUpper}}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
	</Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatAccentButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFlatAccentTextButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatTextButton}">
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFlatUpperTextButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <ControlTemplate.Resources>
            <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource UpperTextBlock}"/>
          </ControlTemplate.Resources>
          <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}">
            <wpf:Ripple
              Tag="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
              Content="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource TranslateAndToUpper}}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatAccentUpperTextButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatUpperTextButton}">
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFlatOverlayButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Foreground" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Grid>
            <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}"/>
            <Rectangle x:Name="rectangle" Fill="{TemplateBinding Foreground}" Width="{Binding ElementName=contentPresenter, Path=ActualWidth}" Height="{Binding ElementName=contentPresenter, Path=ActualHeight}">
              <Rectangle.OpacityMask>
                <VisualBrush TileMode="None" Stretch="None">
                  <VisualBrush.Visual>
                    <ContentPresenter
                      x:Name="contentPresenter"
                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                      Margin="{TemplateBinding Padding}"
                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                  </VisualBrush.Visual>
                </VisualBrush>
              </Rectangle.OpacityMask>
            </Rectangle>
            <wpf:Ripple
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatOverlayAccentButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatOverlayButton}">
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignInvisibleMouseOverButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="BorderBrush" Value="Transparent"/>
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="Padding" Value="0"/>
    <Setter Property="Opacity" Value="0"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <ControlTemplate.Resources>
            <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource UpperTextBlock}"/>
          </ControlTemplate.Resources>
          <Grid>
            <Rectangle x:Name="fillRect" Fill="{TemplateBinding Foreground}" Width="{Binding RelativeSource={RelativeSource TemplatedParent},Path=ActualWidth}" Height="{Binding RelativeSource={RelativeSource TemplatedParent},Path=ActualHeight}"/>
            <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}">
              <wpf:Ripple
                Focusable="False"
                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                RecognizesAccessKey="False"
                Padding="{TemplateBinding Padding}"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            </Border>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"/>
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
              <Setter Property="Opacity" Value="1"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
              <Setter Property="Fill" TargetName="fillRect" Value="{DynamicResource MaterialDesignDarkBackground}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignOutlinedButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="BorderBrush" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
            <wpf:Ripple
              Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignOutlinedOverlayButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="BorderBrush" Value="{DynamicResource MidContrastPrimaryBrush}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Grid>
            <ContentPresenter
              x:Name="contentPresenter"
              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
              Margin="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
              <ContentPresenter.RenderTransform>
                <TranslateTransform X="60000" Y="60000" /> <!-- We use the content presenter as mask, render it offscreen -->
              </ContentPresenter.RenderTransform>
            </ContentPresenter>
            <Border Background="Transparent" x:Name="border" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
            <Rectangle x:Name="rectangle" Fill="{TemplateBinding Foreground}" Width="{Binding ElementName=contentPresenter, Path=ActualWidth}" Height="{Binding ElementName=contentPresenter, Path=ActualHeight}">
              <Rectangle.OpacityMask>
                <VisualBrush TileMode="None" Stretch="None" Visual="{Binding ElementName=contentPresenter}"/>
              </Rectangle.OpacityMask>
            </Rectangle>
            <wpf:Ripple
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFillOutlinedButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignOutlinedButton}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Border Background="{DynamicResource MaterialDesignBackground}" x:Name="border" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
            <wpf:Ripple
              Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFillOutlinedOverlayButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignOutlinedButton}">
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Border Background="{DynamicResource MaterialDesignBackground}" x:Name="border" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
            <Grid x:Name="contentGrid">
              <ContentPresenter
                x:Name="contentPresenter"
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                Margin="{TemplateBinding Padding}"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                <ContentPresenter.RenderTransform>
                  <TranslateTransform X="60000" Y="60000" /> <!-- We use the content presenter as mask, render it offscreen -->
                </ContentPresenter.RenderTransform>
              </ContentPresenter>
              <Rectangle
                x:Name="rectangle"
                Fill="{TemplateBinding Foreground}"
                Width="{Binding ElementName=contentPresenter, Path=ActualWidth}"
                Height="{Binding ElementName=contentPresenter, Path=ActualHeight}"
                Margin="{TemplateBinding Padding}"
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                <Rectangle.OpacityMask>
                  <VisualBrush
                    TileMode="None"
                    Stretch="None"
                    AlignmentX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HorizontalContentAlignment, Converter={StaticResource HorizontalAlignmentToAlignmentX}}"
                    Visual="{Binding ElementName=contentPresenter}"/>
                </Rectangle.OpacityMask>
              </Rectangle>
              <wpf:Ripple
                Focusable="False"
                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                RecognizesAccessKey="False"
                Padding="{TemplateBinding Padding}"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            </Grid>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsFocused" Value="True">
              <Setter Property="Background" TargetName="border" Value="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BrushToTransmittantBrushConverter}, ConverterParameter=0.12}"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Background" TargetName="border" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignStatusBarButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignRaisedButton}">
    <Setter Property="Background" Value="{DynamicResource Dentalshare.Status.Arrow}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Grid>
            <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
              <Grid>
                <Border
                  Background="{TemplateBinding Background}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  x:Name="border"/>
                <Grid x:Name="focusBackground" Background="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BrushToTransmittantBrushConverter}, ConverterParameter=0.12}" Visibility="Collapsed"/>
                <ProgressBar
                  x:Name="ProgressBar"
                  Style="{DynamicResource MaterialDesignLinearProgressBar}"
                  Minimum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Minimum)}"
                  Maximum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Maximum)}"
                  Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorForeground)}"
                  Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorBackground)}"
                  Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Value)}"
                  IsIndeterminate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IsIndeterminate)}"
                  Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IsIndicatorVisible), Converter={StaticResource BooleanToVisibilityConverter}}"
                  Height="{TemplateBinding Height}"
                  Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ButtonBase}}, Path=ActualWidth}"
                  Opacity="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Opacity)}"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Center"></ProgressBar>
              </Grid>
            </AdornerDecorator>
            <wpf:Ripple
              Content="{TemplateBinding Content}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              ContentStringFormat="{TemplateBinding ContentStringFormat}"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Visibility" TargetName="focusBackground" Value="Visible"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignToolButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFlatButton}">
    <Setter Property="Foreground" Value="#616161"/>
    <Setter Property="Padding" Value="4"/>
    <Setter Property="wpf:RippleAssist.ClipToBounds" Value="False"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="Button">
          <ControlTemplate.Resources>
            <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource UpperTextBlock}"/>
          </ControlTemplate.Resources>
          <wpf:Ripple
            Tag="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
            Content="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource TranslateAndToUpper}}"
            ContentTemplate="{TemplateBinding ContentTemplate}"
            Focusable="False"
            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
            RecognizesAccessKey="False"
            Padding="{TemplateBinding Padding}"
            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignToolForegroundButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignToolButton}">
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
  </Style>

  <Style x:Key="MaterialDesignFloatingActionMiniButton" TargetType="{x:Type ButtonBase}">
    <Style.Resources>
      <Style x:Key="{x:Type TextBlock}" BasedOn="{StaticResource ControlContentTextblock}" TargetType="{x:Type TextBlock}"/>
    </Style.Resources>
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
    <Setter Property="wpf:RippleAssist.Feedback" Value="White"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorForeground" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorBackground" Value="{DynamicResource MaterialDesignDivider}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Cursor" Value="Hand"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
    <Setter Property="Padding" Value="1"/>
    <Setter Property="Width" Value="40"/>
    <Setter Property="Height" Value="40"/>
    <Setter Property="wpf:ButtonProgressAssist.Opacity" Value="1"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Grid>
            <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
              <Ellipse
                Fill="{TemplateBinding Background}"
                Stroke="{TemplateBinding BorderBrush}"
                StrokeThickness="{TemplateBinding BorderThickness}"
                Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}"
                x:Name="border"></Ellipse>
            </AdornerDecorator>
            <ProgressBar
              x:Name="ProgressBar"
              Style="{DynamicResource MaterialDesignCircularProgressBar}"
              Minimum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Minimum)}"
              Maximum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Maximum)}"
              Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorForeground)}"
              Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IndicatorBackground)}"
              Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.Value)}"
              IsIndeterminate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IsIndeterminate)}"
              Opacity="{Binding RelativeSource={RelativeSource TemplatedParent},  Path=(wpf:ButtonProgressAssist.Opacity)}"
              Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ButtonProgressAssist.IsIndicatorVisible), Converter={StaticResource BooleanToVisibilityConverter}}"
              Margin="-8"
              Width="{TemplateBinding Width, Converter={StaticResource MathAddConverter}, ConverterParameter={StaticResource ProgressRingStrokeWidth}}"
              Height="{TemplateBinding Height, Converter={StaticResource MathAddConverter}, ConverterParameter={StaticResource ProgressRingStrokeWidth}}"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Stretch"
              RenderTransformOrigin=".5, .5">
              <ProgressBar.RenderTransform>
                <TransformGroup>
                  <ScaleTransform ScaleX="0" ScaleY="0"/>
                </TransformGroup>
              </ProgressBar.RenderTransform>
            </ProgressBar>
            <Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"/>
            <wpf:Ripple
              Content="{TemplateBinding Content}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              Focusable="False"
              Clip="{Binding ElementName=GeometryEllipse, Path=RenderedGeometry}"
              ClipToBounds="True"
              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
              RecognizesAccessKey="False"
              Padding="{TemplateBinding Padding}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            <Ellipse x:Name="GeometryEllipse" Fill="Transparent" IsHitTestVisible="False" Focusable="False"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="Button.IsDefaulted" Value="true">
              <Setter Property="Stroke" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
              <Setter TargetName="border" Property="wpf:ShadowAssist.Darken" Value="True"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
              <Setter TargetName="border" Property="wpf:ShadowAssist.Darken" Value="True"/>
            </Trigger>
            <Trigger Property="wpf:ButtonProgressAssist.IsIndicatorVisible" Value="True">
              <Trigger.EnterActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation Duration="0:0:0.2" From=".9" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="ProgressBar"/>
                    <DoubleAnimation Duration="0:0:0.2" From=".9" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="ProgressBar"/>
                  </Storyboard>
                </BeginStoryboard>
              </Trigger.EnterActions>
              <Trigger.ExitActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation Duration="0:0:0.2" From="1" To=".9" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="ProgressBar"/>
                    <DoubleAnimation Duration="0:0:0.2" From="1" To=".9" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="ProgressBar"/>
                  </Storyboard>
                </BeginStoryboard>
              </Trigger.ExitActions>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFloatingActionButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFloatingActionMiniButton}">
    <Setter Property="Width" Value="56"/>
    <Setter Property="Height" Value="56"/>
  </Style>

  <Style x:Key="MaterialDesignFloatingActionMiniLightButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFloatingActionMiniButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorForeground" Value="{DynamicResource PrimaryHueDarkBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFloatingActionMiniDarkButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFloatingActionMiniButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueDarkBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueDarkBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueDarkForegroundBrush}"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorForeground" Value="{DynamicResource PrimaryHueLightBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFloatingActionMiniAccentButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFloatingActionMiniButton}">
    <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorForeground" Value="{DynamicResource PrimaryHueMidBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFloatingActionLightButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFloatingActionButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorForeground" Value="{DynamicResource PrimaryHueDarkBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFloatingActionDarkButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFloatingActionButton}">
    <Setter Property="Background" Value="{DynamicResource PrimaryHueDarkBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueDarkBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource PrimaryHueDarkForegroundBrush}"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorForeground" Value="{DynamicResource PrimaryHueLightBrush}"/>
  </Style>

  <Style x:Key="MaterialDesignFloatingActionAccentButton" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MaterialDesignFloatingActionButton}">
    <Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
    <Setter Property="wpf:ButtonProgressAssist.IndicatorForeground" Value="{DynamicResource PrimaryHueMidBrush}"/>
  </Style>

  <!-- MessageBoxButton -->
  <Style x:Key="MessageBoxButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignFillOutlinedOverlayButton}"/>

  <!-- Button -->
  <Style x:Key="{x:Type Button}" BasedOn="{StaticResource MaterialDesignOutlinedButton}" TargetType="{x:Type Button}"/>

  <!-- RepeatButton -->
  <Style x:Key="{x:Type RepeatButton}" BasedOn="{StaticResource MaterialDesignUpperRaisedButton}" TargetType="{x:Type RepeatButton}"/>

</ResourceDictionary>
